<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      /**
       * @param {number[]} nums
       * @return {number[]}
       */
      var sortArrayByParity = function (nums) {
        let res = [];
        for (let key in nums) {
          if (nums[key] % 2 === 0) {
            res.push(nums[key]);
          }
        }
        for (let key in nums) {
          if (nums[key] % 2 !== 0) {
            res.push(nums[key]);
          }
        }
        return res;
      };
    </script>
  </body>
</html>
